//jiudge: 23888: 1686552841
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
using namespace std;
const int N = 2e6 + 5;
set<int> s;
int n;
int a[N], b[N];
bool f;
void del(int x) {
for (int i = 2; i * i <= x; i ++) {
if (x % i == 0) {
for (int j = i; j < N; j += i) if (s.count(j)) s.erase(j);
while (x % i == 0) x /= i;
}
}
if (x > 1) for (int i = x; i < N; i += x) if (s.count(i)) s.erase(i);
}
int main() {
IOS
cin >> n;
for (int i = 1; i <= n; i ++) cin >> a[i];
for (int i = 2; i < N; i ++) s.insert(i);
for (int i = 1; i <= n; i ++) {
auto it = f ? s.begin() : s.lower_bound(a[i]);
if (*it > a[i]) f = 1; b[i] = *it; del(*it);
}
for (int i = 1; i <= n; i ++) cout << b[i] << ' ';
return 0;
}
714B - Filya and Homework | 31A - Worms Evolution |
1691A - Beat The Odds | 433B - Kuriyama Mirai's Stones |
892A - Greed | 32A - Reconnaissance |
1236D - Alice and the Doll | 1207B - Square Filling |
1676D - X-Sum | 1679A - AvtoBus |
1549A - Gregor and Cryptography | 918C - The Monster |
4B - Before an Exam | 545B - Equidistant String |
1244C - The Football Season | 1696B - NIT Destroys the Universe |
1674A - Number Transformation | 1244E - Minimizing Difference |
1688A - Cirno's Perfect Bitmasks Classroom | 219A - k-String |
952A - Quirky Quantifiers | 451B - Sort the Array |
1505H - L BREAK into program | 171E - MYSTERIOUS LANGUAGE |
630D - Hexagons | 1690D - Black and White Stripe |
1688D - The Enchanted Forest | 1674C - Infinite Replacement |
712A - Memory and Crow | 1676C - Most Similar Words |